<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>个人博客</title>
    <meta name="keywords" content="个人博客" />
    <meta name="description" content="" />
    <link rel="stylesheet" href="css/index.css"/>
    <link rel="stylesheet" href="css/style.css"/>
    <script type="text/javascript" src="js/jquery1.42.min.js"></script>
    <script type="text/javascript" src="js/jquery.SuperSlide.2.1.1.js"></script>
    <script src="https://cdn.bootcss.com/jquery/2.1.2/jquery.min.js"></script>
    <script>

        $(function(){

            $("a.del").click(function(){

                var delId = $(this).attr("data-id");

                if(confirm("提示：确认删除？")) {

                    $.post('public/ajax/del_info.php', {delId:delId}, function (data) {
                        if (data == 'ok') {
                            window.location.href = "index.php";
                            return;
                        } else {
                            alert('提示：删除有误!');
                            return;
                        }
                    });

                }


            });

        });

    </script>
</head>
<body>

<?php

//连接数据库
include 'inc/conn.php';

//验证用户登陆
include 'inc/checkSesion.php';

$pageSize = 2; //每页显示条数

//总条数
$sqlCount = "SELECT COUNT(id) FROM blog_info WHERE id IS NOT NULL";
$resCount = mysqli_query($conn, $sqlCount);
if ($rwtCount = mysqli_fetch_array($resCount)) {
    $infoCount = $rwtCount[0]; //总条数
}

$pageCount = ceil($infoCount/$pageSize); //总页数

$page = intval($_GET['page']); //当前页数
if ($page > $pageCount) {
    $page = $pageCount;
} elseif ($page < 1) {
    $page = 1;
}

$limit = ($page - 1) * $pageSize;


//读取文章内容
$sql = "SELECT id, blog_title,blog_content,add_time FROM blog_info WHERE id IS NOT NULL ORDER BY id DESC LIMIT $limit, $pageSize  ";
$res = mysqli_query($conn, $sql);
while ($rwt = mysqli_fetch_array($res)) {
    $list[] = $rwt;
}
//var_dump($list);
?>

<!--header start-->
<div id="header">
    <h1>个人博客</h1>
    <p>青春是打开了,就合不上的书。人生是踏上了，就回不了头的路，爱情是扔出了，就收不回的赌注。</p>
</div>
<!--header end-->
<!--nav-->
<div id="nav">
    <ul>
        <li><a href="index.php">首页</a></li>
        <li><a href="text1.php">登录</a></li>
        <li><a href="changePwd1.php">修改密码</a></li>
        <li><a href="add_blog1.php">发布文章</a></li>
        <li><a href="BK.php">数据管理</a></li>
        <li><a href="learn.html">学无止境</a></li>
        <li><a href="guestbook.html">留言板</a></li>
        <div class="clear"></div>
    </ul>
</div>
<!--nav end-->
<!--content start-->
<div id="content">
    <!--left-->
    <div class="left" id="c_left">
        <div class="s_tuijian">
            <h2>文章<span>推荐</span></h2>
        </div>
        <div class="content_text">
            <!--wz-->

            <div class="wz">

                    <?php
                    foreach ($list as $val) {
                        "<tr>
               <td >".$val['id']."</td>
               <td >".$val['blog_title']."</td>
                <td >".$val['blog_content']."</td>
               <td  >".date('Y-m-d H:i:s', $val['add_time'])."</td>
               <td>
                    <a href='edit_blog1.php?id=".$val['id']."'>编辑</a>
                    <a href='javascript:void(0);' data-id='".$val['id']."' class='del'>删除</a>
               </td>
          </tr>";}
                    ?>



                </table>
                <h3><a href="#" title="浅谈：html5和html的区别"></a></h3>

            </div>
            <!--wz end-->
            <!--wz-->
            <div class="wz">
                <h3><a href="#" title=""><?php

                        echo ($val['blog_title'])
                        ?></a></h3>
                <dl>
                    <dt><img src="images/s1.jpg" width="200" height="123" alt=""></dt>
                    <dd>
                        <p class="dd_text_1"><?php

                            echo ($val['blog_content'])
                            ?></p>
                        <p class="dd_text_2">
                            <span class="left author"><?php

                                echo ($val['id'])
                                ?></span><span class="left sj"><?php

                                echo (date('Y-m-d H:i:s', $val['add_time']))
                                ?></span>
                            <span class="left fl">分类:<a href="#" title="学无止境">学无止境</a></span><span class="left yd"><a href="#" title="阅读全文">阅读全文</a>
               </span>
                        <div class="clear"></div>
                        </p>
                    </dd>
                    <div class="clear"></div>
                </dl>
            </div>
            <!--wz end-->
            <!--wz-->
            <div class="wz">
                <h3><a href="#" title=""><?php

                        echo ($val['blog_title'])
                        ?></a></h3>
                <dl>
                    <dt><img src="images/s2.jpg" width="200" height="123" alt=""></dt>
                    <dd>
                        <p class="dd_text_1"><?php

                            echo ($val['blog_content'])
                            ?></p>
                        <p class="dd_text_2">
                            <span class="left author"><?php

                                echo ($val['id'])
                                ?></span><span class="left sj"><?php

                                echo (date('Y-m-d H:i:s', $val['add_time']))
                                ?></span>
                            <span class="left fl">分类:<a href="#" title="学无止境">学无止境</a></span><span class="left yd"><a href="#" title="阅读全文">阅读全文</a>
               </span>
                        <div class="clear"></div>
                        </p>
                    </dd>
                    <div class="clear"></div>
                </dl>>
            </div>
            <!--wz end-->
            <!--wz-->
            <div class="wz">
                <h3><a href="#" title=""><?php

                        echo ($val['blog_title'])
                        ?></a></h3>
                <dl>
                    <dt><img src="images/s3.jpg" width="200" height="123" alt=""></dt>
                    <dd>
                        <p class="dd_text_1"><?php

                            echo ($val['blog_content'])
                            ?></p>
                        <p class="dd_text_2">
                            <span class="left author"><?php

                                echo ($val['id'])
                                ?></span><span class="left sj"><?php

                                echo (date('Y-m-d H:i:s', $val['add_time']))
                                ?></span>
                            <span class="left fl">分类:<a href="#" title="学无止境">学无止境</a></span><span class="left yd"><a href="#" title="阅读全文">阅读全文</a>
               </span>
                        <div class="clear"></div>
                        </p>
                    </dd>
                    <div class="clear"></div>
                </dl>
            </div>
            <!--wz end-->
            <!--wz-->
            <div class="wz">
                <h3><a href="#" title=""><?php

                        echo ($val['blog_title'])
                        ?></a></h3>
                <dl>
                    <dt><img src="images/s.jpg" width="200" height="123" alt=""></dt>
                    <dd>
                        <p class="dd_text_1"><?php

                            echo ($val['blog_content'])
                            ?></p>
                        <p class="dd_text_2">
                            <span class="left author"><?php

                                echo ($val['id'])
                                ?></span><span class="left sj"><?php

                                echo (date('Y-m-d H:i:s', $val['add_time']))
                                ?></span>
                            <span class="left fl">分类:<a href="#" title="学无止境">学无止境</a></span><span class="left yd"><a href="#" title="阅读全文">阅读全文</a>
               </span>
                        <div class="clear"></div>
                        </p>
                    </dd>
                    <div class="clear"></div>
                </dl>
            </div>
            <!--wz end-->


        </div>
    </div>
    <!--left end-->
    <!--right-->
    <div class="right" id="c_right">
        <div class="s_about">
            <h2>关于博主</h2>
            <img src="images/my.jpg" width="230" height="230" alt="博主"/>
            <p>博主：XX</p>
            <p>职业：web前端、视觉设计</p>
            <p>简介：</p>
            <p>
                <a href="#" title="联系博主"><span class="left b_1"></span></a><a href="#" title="加入QQ群，一起学习！"><span class="left b_2"></span></a>
            <div class="clear"></div>
            </p>
        </div>
        <!--栏目分类-->
        <div class="lanmubox">
            <div class="hd">
                <ul><li>精心推荐</li><li>最新文章</li><li class="hd_3">随机文章</li></ul>
            </div>
            <div class="bd">
                <ul>
                    <li><a href="#" title="网站项目实战开发（-）">网站项目实战开发（-）</a></li>
                    <li><a href="#" title="关于响应式布局">关于响应式布局</a></li>
                    <li><a href="#" title="如何创建个人博客网站">如何创建个人博客网站</a></li>
                    <li><a href="#" title="网站项目实战开发（二）">网站项目实战开发（二）</a></li>
                    <li><a href="#" title="为什么新站前期排名老是浮动？(转)">为什么新站前期排名老是浮动？(转)</a></li>
                </ul>
                <ul>
                    <li><a href="#" title="网站项目实战开发（-）">网站项目实战开发（-）</a></li>
                    <li><a href="#" title="关于响应式布局">关于响应式布局</a></li>
                    <li><a href="#" title="如何创建个人博客网站">如何创建个人博客网站</a></li>
                    <li><a href="#" title="网站项目实战开发（二）">网站项目实战开发（二）</a></li>
                    <li><a href="#" title="为什么新站前期排名老是浮动？(转)">为什么新站前期排名老是浮动？(转)</a></li>
                </ul>
                <ul>
                    <li><a href="#" title="网站项目实战开发（-）">网站项目实战开发（-）</a></li>
                    <li><a href="#" title="关于响应式布局">关于响应式布局</a></li>
                    <li><a href="#" title="如何创建个人博客网站">如何创建个人博客网站</a></li>
                    <li><a href="#" title="网站项目实战开发（二）">网站项目实战开发（二）</a></li>
                    <li><a href="#" title="为什么新站前期排名老是浮动？(转)">为什么新站前期排名老是浮动？(转)</a></li>
                </ul>


            </div>
        </div>
        <!--end-->
        <div class="link">
            <h2>友情链接</h2>
            <p><a href="#">段亮个人博客</a></p>
        </div>
    </div>
    <!--right end-->
    <div class="clear"></div>
</div>
<!--content end-->
<!--footer start-->
<div id="footer">
    <p>Design by:<a href="http://www.duanliang920.com" target="_blank">少年</a> 2014-8-9</p>
</div>
<!--footer end-->
<script type="text/javascript">jQuery(".lanmubox").slide({easing:"easeOutBounce",delayTime:400});</script>
<script  type="text/javascript" src="js/nav.js"></script>

</body>
</html>